<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script src="./02-其他资料/分类导航/axios.js"></script>
  <script>
    // axios 返回的是一个promise
    // const res = axios({
    //   url: 'http://ajax-api.itheima.net/api/news',
    // })
    //   .then()
    //   .catch()
    // console.log(res);

    //promise 原生写法
    const p = new Promise((resolve, reject) => {
      //请求成功
      setTimeout(() => {
        console.log('异步执行完了')
        resolve('成功了')
      }, 1000);
      // resolve('成功')
      //请求失败
      // reject('失败')
    })
      .then((res) => {
        console.log('res', res);
      })
      .catch((err) => console.log('err', err))
    console.log(p)
  </script>
</body>

</html>